<?php
require_once("config.php");
require_once("functions.php");
$title = "Domain Statistics";
require_once("header.php");
if (!$allow_url_fopen) {
	echo '<span class="error"><b>Note</b>: Please enable \'<em>allow_url_fopen</em>\' option in PHP configuration file</span><br/>';
}

$domain = @$_REQUEST['domain'];
@list($with_www, $without_domain) = get_domain($domain);

?>
<table width="98%" cellpadding="0" cellspacing="0" class="mytable">
  <tr>
    <td valign="top" colspan="2"></td>
  </tr>
  <tr>
    <td valign="top" align="middle" colspan="2">
        <form action="domain_stats.php" method="get" name="pageform">
          <table width="98%" border="0">
            <tbody>
              <tr>
                <td valign="top" width="98%" height="91"><table height="76" width="98%">
                    <tbody>
                      <tr>
                        <td><table cellspacing="5" width="98%" border="0">
                            <tbody>
                              <tr>
                                <td width="184" height="28"><strong>Your domain: </strong></td>
                                <td height="28"><input size="33" value="<?php echo @$without_domain; ?>" name="domain" /></td>
                                <td height="28"><input name="submit" type="submit" value="Check!" class="button" /></td>
                              </tr>
                              <tr>
                                <td height="21">&nbsp;</td>
                                <td valign="top" colspan="2" height="21">(eg.   webpromotioner.com)</td>
                              </tr>
                            </tbody>
                        </table></td>
                      </tr>
                    </tbody>
                </table></td>
              </tr>
            </tbody>
          </table>
        </form>
    </td>
  </tr>
</table>
<br>
<?php
if (!empty($domain) ) {
?>
<table width="98%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="25" class="headingbar"><strong>Domain Name:&nbsp;&nbsp;&nbsp; <?php echo $without_domain; ?></strong></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="25" class="tr1"><strong>Statistics - General</strong></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td align="right"><table width="95%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="left" class="bodytext"><div id="general">Loading...please wait....</div></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="25" class="tr1"><strong>Statistics - Google</strong></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td align="right"><table width="95%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="left" class="bodytext"><div id="google">Loading....</div></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="25" class="tr1"><strong>Statistics - Yahoo</strong></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td align="right"><table width="95%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="left" class="bodytext"><div id="yahoo">Loading....</div></td>
      </tr>
    </table>
   </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="25" class="tr1"><strong>Statistics - MSN</strong></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td align="right"><table width="95%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="left" class="bodytext"><div id="msn">Loading....</div></td>
      </tr>
    </table>
   </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
<script>
var domain = '<?php echo $domain; ?>';

function do_forgoogle(ob) {
	if(ob.responseText != '') {
		try{
			display_text('google', ob.responseText);
		} catch(e) {
		}
	}
}

function do_foryahoo(ob) {
	if(ob.responseText != '') {
		try{
			display_text('yahoo', ob.responseText);
		} catch(e) {
		}
	}
}

function do_formsn(ob) {
	if(ob.responseText != '') {
		try{
			display_text('msn', ob.responseText);
		} catch(e) {
		}
	}
}

function do_forgeneral(ob) {
	if(ob.responseText != '') {
		try{
			display_text('general', ob.responseText);
		} catch(e) {
		}
	}
}

function get_google() {
	xmlhttp_config = {"URL":"query_google.php","METHOD":"POST","ASYNCH":true};
	xmlHRH = new xmlHttpRequestHandler(xmlhttp_config);
	xmlHRH.setData("domain="+domain+"");
	xmlHRH.send(do_forgoogle);
	
}
function get_yahoo() {
	xmlhttp_config = {"URL":"query_yahoo.php","METHOD":"POST","ASYNCH":true};
	xmlHRH = new xmlHttpRequestHandler(xmlhttp_config);
	xmlHRH.setData("domain="+domain+"");
	xmlHRH.send(do_foryahoo);
	
}
function get_msn() {
	xmlhttp_config = {"URL":"query_msn.php","METHOD":"POST","ASYNCH":true};
	xmlHRH = new xmlHttpRequestHandler(xmlhttp_config);
	xmlHRH.setData("domain="+domain+"");
	xmlHRH.send(do_formsn);
	
}
function get_general() {
	xmlhttp_config = {"URL":"query_general.php","METHOD":"POST","ASYNCH":true};
	xmlHRH = new xmlHttpRequestHandler(xmlhttp_config);
	xmlHRH.setData("domain="+domain+"");
	xmlHRH.send(do_forgeneral);
	
}

function display_text(divs, response_text) {
	document.getElementById(divs).innerHTML = response_text;
}

setTimeout("get_google()",100);
setTimeout("get_yahoo()",100);
setTimeout("get_msn()",100);
get_general();

</script>
<?php
}
require_once("footer.php");
?>